package com.imooc.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.imooc.mapper.GoodsInfoMapper;
import com.imooc.pojo.GoodsInfo;
import com.imooc.service.GoodsInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
@Service
public class GoodsInfoServiceImpl implements GoodsInfoService {

    @Autowired
    private GoodsInfoMapper goodsInfoMapper;

    @Override
    public PageInfo<GoodsInfo> getAllGoodsInfo(Map<String, Object> map, int currentPage, int pageSize) {
        PageHelper.startPage(currentPage, pageSize);
        List<GoodsInfo> list = goodsInfoMapper.selectAllInfo(map);
        PageInfo<GoodsInfo> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public GoodsInfo getGoodsInfo(Map<String, Object> map) {
        return goodsInfoMapper.getGoodsInfo(map);
    }

    @Override
    public void truncateGoodsInfo() {
        goodsInfoMapper.truncateGoodsInfo();
    }

    @Override
    public void deleteByParam(Map<String, Object> param) {
        goodsInfoMapper.deleteByParam(param);
    }

    @Override
    public void updateByParam(GoodsInfo goodsInfo) {
        goodsInfoMapper.updateByParam(goodsInfo);
    }
}
